<template>
  <div class="app-container">
    <!--表单-->
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item label="日期">
        <el-date-picker
          v-model="day"
          type="date"
          placeholder="选择要统计的日期"
          value-format="yyyy-MM-dd"
        />
      </el-form-item>

      <el-button :disabled="btnDisabled" type="primary" @click="genarateData()"
        >生成</el-button
      >
    </el-form>
  </div>
</template>

<script>
import { updateStatisticsInfo } from "@/api/statistics";

export default {
  data() {
    return {
      day: "",
      btnDisabled: false, // 按钮禁用状态
    };
  },

  methods: {
    // 生成统计数据
    async genarateData() {
      if (this.day) {
        let result = await updateStatisticsInfo(this.day);
        if (result.code === 20000) {
          this.$message.success("统计成功！");
          return false;
        }
        this.$message.success("统计失败," + result.message);
      }
    },
  },
};
</script>
